<?php

/**
 * Item form base class.
 *
 * @package    form
 * @subpackage item
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseItemForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_item'    => new sfWidgetFormInputHidden(),
      'id_tipo'    => new sfWidgetFormDoctrineChoice(array('model' => 'Tipo', 'add_empty' => false)),
      'id_usuario' => new sfWidgetFormDoctrineChoice(array('model' => 'DadosUsuario', 'add_empty' => false)),
      'nm_item'    => new sfWidgetFormInput(),
      'ds_item'    => new sfWidgetFormTextarea(),
      'ds_resumo'  => new sfWidgetFormInput(),
      'st_item'    => new sfWidgetFormInputCheckbox(),
      'destaque'   => new sfWidgetFormInputCheckbox(),
      'pb_item'    => new sfWidgetFormInputCheckbox(),
      'vl_item'    => new sfWidgetFormInput(),
      'ds_tags'    => new sfWidgetFormInput(),
      'url'        => new sfWidgetFormInput(),
      'slug'       => new sfWidgetFormInput(),
      'created_at' => new sfWidgetFormDateTime(),
      'updated_at' => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id_item'    => new sfValidatorDoctrineChoice(array('model' => 'Item', 'column' => 'id_item', 'required' => false)),
      'id_tipo'    => new sfValidatorDoctrineChoice(array('model' => 'Tipo')),
      'id_usuario' => new sfValidatorDoctrineChoice(array('model' => 'DadosUsuario')),
      'nm_item'    => new sfValidatorString(array('max_length' => 100)),
      'ds_item'    => new sfValidatorString(array('required' => false)),
      'ds_resumo'  => new sfValidatorString(array('max_length' => 90, 'required' => false)),
      'st_item'    => new sfValidatorBoolean(),
      'destaque'   => new sfValidatorBoolean(),
      'pb_item'    => new sfValidatorBoolean(),
      'vl_item'    => new sfValidatorNumber(array('required' => false)),
      'ds_tags'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'url'        => new sfValidatorString(array('max_length' => 200, 'required' => false)),
      'slug'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at' => new sfValidatorDateTime(array('required' => false)),
      'updated_at' => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Item', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('item[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Item';
  }

}
